/* =========================================================================
 *
 * MainMenu.js
 *  This script contains the game logic that acts as an App for the Main Menu
 *  of the game.
 *
 * ========================================================================= */
ECS.MainMenu = function MainMenu (){

	var entities = {};
	
	// Setup systems
	ECS.MainMenu.systems = {
        render: ECS.systems.render
    };
    
    // Populate with the required entities
	
    // Create the Background
	var background = new ECS.Entity();
	background.addComponent (new ECS.Components.Image("Sprites/TestImages/The_Last_World_war.jpg"));
	background.components.Image.image.onload = function () {
		var coords = {};
		coords.x = ECS.$canvas.width / 2 - background.components.Image.image.width / 2;
		coords.y = ECS.$canvas.height / 2 - background.components.Image.image.height / 2;
		background.addComponent (new ECS.Components.Position( coords ) );
	}
	entities[background.id]=background;
	
	var startButton = new ECS.Entity();
	startButton.addComponent (new ECS.Components.Image("Sprites/TestImages/start_button.png"));
	startButton.components.Image.image.onload = function () {
		var coords = {};
		coords.x = ECS.$canvas.width / 2 - startButton.components.Image.image.width / 2;
		coords.y = ECS.$canvas.height / 2 - startButton.components.Image.image.height / 2;
		startButton.addComponent (new ECS.Components.Position( coords ) );
	}
	entities[startButton]=startButton;
	
	// store reference to entities
    ECS.entities = entities;
    
    return this;
}

ECS.MainMenu.prototype.runSystems = function runSystems() {
	
	// Run the Main Menu systems
	ECS.MainMenu.systems.render(ECS.entities);
}